import json

from django.shortcuts import render

from orderApp.service.cartService import CartService
from orderApp.service.orderService import OrderService

orderService = OrderService()
cartService = CartService()

def cartPage(request):
    user = json.loads(request.session['user'])
    result = cartService.getByUserId(userId=user['id'])
    return render(request=request,template_name='cargo.html',context={"result":result})
def placeOrderPage(request):
    return render(request,'place_order.html')
def successPage(request):
    user = json.loads(request.session['user'])
    orderId = request.GET['id']
    result = orderService.getOrderDetailById(orderId=orderId)
    print(result)
    return render(request=request,
                  template_name="success.html",
                  context={"result":result})